<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="../session.jsp"%>
<!DOCTYPE html>
<html lang="ko">
  <head>
  	<%@ include file="../head.jsp"%>
  	<script src="resources/js/jquery.js"></script>
	<script src="resources/js/bootstrap.min.js"></script>
  </head>
  <body>
  	<%@ include file="../menu.jsp"%>
	<div class="container">
		<div class="page-header clearfix">
			<h2 class="pull-left">레이아웃관리</h2>
		</div>
		
		<div class="table-responsive">
			<table class="table table-striped table-hover">
				<thead>
					<tr class="warning row">
						<th class="text-center col-md-5">레이아웃명</th>
						<th class="text-center col-md-5">펼치기/접기여부</th>
						<th class="text-center col-md-2">수정</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${list}" var="item">
						<form id="common${item.idCommon}" method="post" action="editCommonOk"></form>
						<input type="hidden" name="idCommon" value="${item.idCommon}" form="common${item.idCommon}" />
						<tr class="text-center row">
							<td class="col-md-5">${item.commonTitle}</td>
							<td class="col-md-5">
								<label class="radio-inline">
									<input type="radio" name="commonText${item.idCommon}" value="show" form="common${item.idCommon}"
										<c:if test="${item.commonText == 'show'}">checked</c:if> /> 펼치기
								</label>
								<label class="radio-inline">
									<input type="radio" name="commonText${item.idCommon}" value="hidden" form="common${item.idCommon}"
										<c:if test="${item.commonText == 'hidden'}">checked</c:if> /> 접기
								</label>
							</td>
							<td class="col-md-2"><button type="submit" class="btn btn-warning" form="common${item.idCommon}">수정</button></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		
	</div>
	
	<!-- 형식검사 클래스 참조 -->
	<script src="resources/js/string.js"></script>
	<script type="text/javascript">
		$(function() {
			
			<c:forEach items="${list}" var="item">
				$("#common${item.idCommon}").submit(function() {
				
					
					if (!$("input[name='commonText${item.idCommon}']").is(":checked")) {
						alert("펼치기/접기여부를 선택해 주세요");
						$("input[name='commonText${item.idCommon}']").focus();
						return false;
					}
					
					if (!confirm("정말 수정하시겠습니까?")) {
						return false;
					}
				});
			</c:forEach>
			
		});
	</script>
  </body>
</html>